package com.collect.senegal.zhiUtils;

import android.graphics.Paint;
import android.graphics.Typeface;
import android.text.TextUtils;
import android.widget.TextView;

public class TextViewUtil {
    public static void setUnderLine(TextView textView) {
        if (textView != null) {
            textView.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
            textView.getPaint().setAntiAlias(true);
        }
    }

    public static void setTextBlod(TextView textView) {
        if (textView != null) {
            textView.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
        }
    }

    public static void setTextNormal(TextView textView) {
        if (textView != null) {
            textView.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
        }
    }

    public static float getTextWidth(TextView textView){
        if(TextUtils.isEmpty(textView.getText().toString().trim())){
            return 0;
        }
        Paint paint = new Paint();
        paint.setTextSize(textView.getTextSize());
        return paint.measureText(textView.getText().toString().trim());
    }


}
